package com.atguigu.gulimall.thirdpart.controller;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.thirdpart.component.SmsComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description sms控制器
 * @Author zr
 * @Date 2022/12/30 14:41
 **/
@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private SmsComponent smsComponent;

    /**
     * 为需要短信验证的服务提供短信验证功能
     *
     * @param phone 手机号
     * @param code  验证码
     * @return
     */
    @GetMapping("/send/code")
    public R sendCode(@RequestParam("phone") String phone, @RequestParam("code") String code) {
        smsComponent.sendSmsCode(phone, code);
        return R.ok("成功发送验证码");
    }
}
